export let getQueryString=function (name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = location.search.substr(1).match(reg);
    if (r != null) return unescape(decodeURI(r[2])); return null;
}

//将对象元素转换成字符串以作比较
export let obj2key=function (obj, keys){
    var n = keys.length,
        key = [];
    while(n--){
        key.push(obj[keys[n]]);
    }
    return key.join('|');
}
//去重操作
export let uniqeByKeys=function(array,keys){
    var arr = [];
    var hash = {};
    for (var i = 0, j = array.length; i < j; i++) {
        var k = obj2key(array[i], keys);
        if (!(k in hash)) {
            hash[k] = true;
            arr .push(array[i]);
        }
    }
    return arr ;
}
export let getTimes=function(nS,type) {
    var date=new Date(parseInt(nS));
    var year=date.getFullYear();
    var mon = date.getMonth()+1;
    if(mon<10){
        mon="0"+mon;
    }
    var day = date.getDate();
    if(day<10){
        day="0"+day;
    }
    var hours = date.getHours();
    if(hours<10){
        hours="0"+hours;
    }
    var minu = date.getMinutes();
    if(minu<10){
        minu="0"+minu;
    }
    var sec = date.getSeconds();
    if(sec<10){
        sec="0"+sec;
    }
    if(type==''||type==undefined||type==null||type=="YY-MM-DD hh:mm:ss"){
        return year+'-'+mon+'-'+day+' '+hours+':'+minu+':'+sec;
    }else if(type=="YY-MM-DD"){
        return year+'-'+mon+'-'+day;
    }
}
    